#include<iostream>
using namespace std;
long long place(int m,int n);
int main()
{
	int t,m,n;
	cin>>t;
	while(t--)
	{
		cin>>m>>n;
		cout<<place(m,n)<<endl;
	}
    return 0;
}
long long place(int m,int n)
{
	if(n>m)
		return place(m,m);
	if(m==0)
		return 1;
	if(n==0)
		return 0;
	return place(m,n-1)+place(m-n,n);
	
}
